package tree;

public class BinaryTree {

    // 创建一颗二叉树
    public TreeNode create() {
        TreeNode A = new TreeNode('A');
        TreeNode B = new TreeNode('B');
        TreeNode C = new TreeNode('C');
        TreeNode D = new TreeNode('D');
        TreeNode E = new TreeNode('E');
        TreeNode F = new TreeNode('F');
        TreeNode G = new TreeNode('G');
        TreeNode H = new TreeNode('H');
        A.left = B;
        A.right = C;
        B.left = D;
        B.right = E;
        C.left = F;
        C.right = G;
        E.right = H;
        return A;
    }
}

// 表示二叉树的每个节点
class TreeNode {
    public int val;// 节点值
    public TreeNode left;//左孩子
    public TreeNode right;//右孩子
    // 构造方法
    public TreeNode(int val) {
        this.val = val;
    }
}